<template>
  <div class="card">
    <a-spin :spinning="loading">
      <a-form :label-col="{ span: 5 }" :wrapper-col="{ span: 14 }">
        <a-form-item label="实名认证引导">
          <a-switch v-model="form.guid_realname" checked-children="开" un-checked-children="关" />
        </a-form-item>
        <a-form-item label="添加卡引导">
          <a-switch v-model="form.guid_bind_card" checked-children="开" un-checked-children="关" />
        </a-form-item>
      </a-form>
      <a-form style="margin: 20px 0" :label-col="{ span: 6 }" :wrapper-col="{ span: 14 }">
        <a-form-item :wrapper-col="{ span: 14, offset: 6 }">
          <a-button type="primary" style="margin-right: 10px" @click="upload">提交</a-button>
          <a-button @click="getInfo">重置</a-button>
        </a-form-item>
      </a-form>
    </a-spin>
  </div>
</template>

<script>
import { getAppListAPI } from '@/api/product.js'
import { getIncomeListAPI } from '@/api/follow.js'
export default {
  name: 'appConfigManagement',
  data() {
    return {
      loading: false,
      form: {}
    }
  },
  created() {
    this.getInfo()
  },
  methods: {
    async getInfo() {
      try {
        this.loading = true
        const { data } = await getAppListAPI({ brand_id: process.env.VUE_APP_BRAND_ID, scene: 'app_module' })
        this.form = data
      } finally {
        this.loading = false
      }
    },
    async upload() {
      const send = {
        brand_id: process.env.VUE_APP_BRAND_ID,
        scene: 'app_module',
        guid_bind_card: this.form.guid_bind_card,
        guid_realname: this.form.guid_realname
      }
      try {
        const result = await getIncomeListAPI(send)
        this.$message.success(result.msg)
        this.getInfo()
      } catch (error) {
        this.$message.error(error.data.msg)
      }
    }
  }
}
</script>

<style lang="less" scoped></style>
